GBML manual / Text

draw_text_sheared

Draws text in world space, scaled, turned and slanted: everything draw_text_warped does, plus two more numbers that slant the whole line the way italic writing slants. xshear slides the top of the letters sideways (a positive number leans them right) and yshear lifts one end of the line (a positive number lifts the right end). (x, y) is the same LEFT/CENTER/RIGHT anchor draw_text already uses, and the point the line is scaled, turned and slanted around, so the line stays where you put it. Inside a Draw GUI event it is fixed to the screen instead, and (x, y) counts from the screen’s top-left pixel.

Works differently on Game Boy - The Game Boy cannot lean letters one by one: with an xshear a text on the screen leans in 4 steps of 2 lines (Draw GUI events only); otherwise the line is turned and lifted by yshear in 8-pixel steps. The size is not used.

Works differently on Game Boy Color - The Game Boy Color cannot lean letters one by one: with an xshear a text on the screen leans in 4 steps of 2 lines (Draw GUI events only); otherwise the line is turned and lifted by yshear in 8-pixel steps. The size is not used.

Sega Genesis: not available

On other consoles this differs: see Side by side and How the consoles differ.

Syntax

draw_text_sheared(x, y, text, xscale, yscale, angle, xshear, yshear)

Arguments

NameType
xreal
yreal
textstring
xscalereal
yscalereal
anglereal
xshearreal
yshearreal

Returns

Nothing.

Description

Everything draw_text_warped does, plus a slant: xshear slides the top of the letters sideways and yshear lifts one end of the line. It is how italic writing slants, and it takes the same two numbers as draw_sprite_sheared and the xshear and yshear variables, so they mean the same thing here:

The first six arguments are exactly draw_text_warped's, in the same order, so a call that already scales or turns text only needs two more numbers on the end. One call can scale, turn and slant a line at once, so there is no second name for text that does all three. (A line that is curved away from you as well as slanted is draw_text_3d_sheared.)

(x, y) is a place in the room, counted from the room's top-left corner. It is the same text_align-resolved spot draw_text uses, and it is also the point the line is scaled, turned and slanted around. The line stays where you put it: slanting a word does not slide it along the ground.

A real capture - the word SLANT three times, side by side. On the left it is plain. In the middle it leans to the right, like italic writing (xshear 0.5). On the right it climbs, with its right end higher than its left (yshear 0.25).A real capture - the word SLANT three times, side by side. On the left it is plain. In the middle it leans to the right, like italic writing (xshear 0.5). On the right it climbs, with its right end higher than its left (yshear 0.25).
A real capture - the word SLANT three times, side by side. On the left it is plain. In the middle it leans to the right, like italic writing (xshear 0.5). On the right it climbs, with its right end higher than its left (yshear 0.25).

Left: draw_text, for comparison. Middle: the first example below, a lean to the right. Right: the second example, the right end lifted. The page's examples put the word above the object and the picture puts all three on one row, so they can be compared. Real pictures from a Game Boy Advance ROM, cropped and shown three times as big.

A real capture, 16 frames played in a loop - the word SLANT written twice, one above the other. The top one never changes. The bottom one leans, and its lean swings from far to the left (xshear -0.80) through standing straight up (0) to far to the right (0.80) and back again, a little like a flag in the wind. The first frame, which is all a viewer that cannot animate shows, is the bottom word leaning to the left (xshear -0.80).A real capture, 16 frames played in a loop - the word SLANT written twice, one above the other. The top one never changes. The bottom one leans, and its lean swings from far to the left (xshear -0.80) through standing straight up (0) to far to the right (0.80) and back again, a little like a flag in the wind. The first frame, which is all a viewer that cannot animate shows, is the bottom word leaning to the left (xshear -0.80).
A real capture, 16 frames played in a loop - the word SLANT written twice, one above the other. The top one never changes. The bottom one leans, and its lean swings from far to the left (xshear -0.80) through standing straight up (0) to far to the right (0.80) and back again, a little like a flag in the wind. The first frame, which is all a viewer that cannot animate shows, is the bottom word leaning to the left (xshear -0.80).

The bottom word's xshear going -0.80, -0.74 ... 0 ... 0.80 and back (the number under the picture is the one in use). The top word is plain and never changes. Sixteen real pictures, two frames apart, played at half the speed of the console. A viewer that does not animate shows the first frame.

Like every draw_ call, it only draws the frames it is called on, so call it every frame the word should stay on screen. Calling it with the same numbers every frame is cheap. Changing a number on every frame (an xshear that swings, say) builds the letters again on every frame, just as a changing scale does for draw_text_warped.

How far it can lean

A note on 12. Twelve is how many sprites one drawn thing can use in every game that has not changed Sprites in one drawn thing under Engine limits in Project Settings (it goes up to 32). Wherever this page says 12 letters, it means that number.

Every letter of a word of 12 letters or fewer is a sprite of its own, and the Game Boy Advance draws a slanted or scaled sprite only inside a box twice as wide and twice as tall as the sprite. A letter is 8 by 8 pixels, so its box is 16 by 16. Anything that slides outside the box is cut off, and nothing can make the box bigger. So how much a word can lean depends on how big it is:

The slant is exact while angle is 0. If the word is turned as well it is still slanted, but the slant is added to the turned picture, not to the screen's rows and columns, so it no longer lines up with them.

Example

draw_text_sheared(x, y - 24, "SLANT", 1, 1, 0, 0.5, 0);

A label reading SLANT, 24 pixels above this instance, at its normal size and not turned, leaning to the right like italic writing.

draw_text_sheared(x, y - 24, "SLANT", 1, 1, 0, 0, 0.25);

The same word with its right end lifted, so it climbs to the right.

draw_text_sheared(x, y - 24, "SLANT", 1.5, 1.5, angle, 0.25, 0);

All three at once: 50% bigger than normal, turned to match this instance's own angle, and leaning a little to the right. angle here is this instance's own variable, not the word's.

On the GBA

Costs ONE shared affine matrix for the whole line, exactly what draw_text_warped costs: the slant is two more numbers in that same matrix, so it takes no extra matrix and no row-by-row effect. A line that is scaled, turned or slanted and has 12 letters or fewer (or the number set under Engine limits in Project Settings, up to 32; spaces do not count) gets a sprite of its own for every letter, so every letter is changed in exactly the same way; that costs 12 of the 128 sprites the screen can show, where plain text costs 3. A longer line is still drawn, but its letters share sprites, up to four to a sprite, so they can come out a little uneven; a development build says so once in the log, and drawing a long line as two calls keeps it even. A scale of 1, no turn and no slant is plain draw_text: no matrix at all. The slant is exact while angle is 0; with a turn as well it is still there, but no longer lines up with the screen’s rows and columns. The console draws each letter inside a box twice its size, so a letter that is big and slanted a lot loses its sides: at a scale of 1 a slant up to 1 fits, and the bigger the scale the less slant fits (see the page). If every one of the hardware’s 32 affine matrices is already in use elsewhere, the text still draws, just upright for that frame.

See also: draw_text_warpeddraw_sprite_sheareddraw_text_3d_shearedxshearysheartext_alignfont_set